#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[n][m];
  for (auto& line: a) {
    for (auto& x: line) {
      cin >> x;
    }
  }
  // memset
  memcpy(b, a, sizeof(a));
  for (int i = 1; i < n - 1; i ++) {
    for (int j = 1; j < m - 1; j ++) {
      int sum = a[i][j] + a[i-1][j] + a[i+1][j] + a[i][j-1] + a[i][j+1];
      b[i][j] = (int)round(sum / 5.0);
    }
  }
  for (auto& line: b) {
    for (auto& x: line) {
      cout << x << ' ';
    }
    cout << endl;
  }
}